/*
 * ﻿Copyright (C) 2013-2014 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.newmainsoftech.eatestutil.container;

import java.io.File;

import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;
import javax.naming.NamingException;

/**
 * Contract for grabbing information of EJB container setup.<br />
 * 
 * @author Arata Y.
 */
public interface EjbContainerMate {
	/**
	 * Get name of either directory of or .jar file of EJB module.<br />
	 * @return Name of either directory of or .jar file of EJB module. 
	 */
	String getEjbModuleName();
	
	/**
	 * Get EJB module stage directory where EJB module files are exploited.<br />
	 * @return Directory exploited EJB module files. 
	 */
	File getEjbModuleStageDir();
	
	/**
	 * Get instance of <code>EJBContainer</code>.<br />
	 * @return Instance of <code>EJBContainer</code>.
	 */
	EJBContainer getEjbContainer();
	/**
	 * Set instance of <code>EJBContainer</code>.<br />
	 * @param ejbContainer
	 */
	void setEjbContainer( EJBContainer ejbContainer);
	
	/**
	 * Get <code>Context</code> from <code>EJBContainer</code>.<br />
	 * @return <code>Context</code> from <code>EJBContainer</code>.
	 */
	Context getContext();
	/**
	 * Set <code>Context</code> from <code>EJBContainer</code>.<br />
	 * @param context
	 */
	void setContext( Context context);
	
	/**
	 * Get <code>{@link ContainerConfig}</code> setting up EE container.<br />
	 * @return <code>{@link ContainerConfig}</code> setting up EE container.
	 */
	ContainerConfig getContainerConfig();
	
	/**
	 * Look for EJB instance in <code>Context</code> of <code>EJBContainer</code>.<br />
	 * @param type
	 * @return EJB instance of specified type.
	 * @throws NamingException
	 */
	<T> T contextLookup( Class<T> type) throws NamingException;
	/**
	 * Look for EJB instance in <code>Context</code> of <code>EJBContainer</code>.<br />
	 * 
	 * @param implClass
	 * @param interfaceClass
	 * @return EJB instance with specified interface.
	 * @throws NamingException
	 */
	<T> T contextLookup( Class<?> implClass, Class<T> interfaceClass) throws NamingException;	
}
